package com.chilly.controller;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import javax.validation.constraints.Max;

/**
 * 参数校验
 * Created by Chilly Cui on 2020/11/17.
 */
@RestController
public class RequestParaValidateController {

    @GetMapping("/api/valid/{id}")
    public ResponseEntity<Integer> getPersonById(@PathVariable("id")
                                                 @Valid
                                                 @Max(value = 5, message = "超过 id 的范围了") Integer id) {
        return ResponseEntity.status(HttpStatus.OK).body(id);
    }
}
